package cn.chinaunicom.sdsi.gacx.author.controller;

import cn.chinaunicom.sdsi.frm.base.BaseController;
import cn.chinaunicom.sdsi.gacx.author.service.AuthorService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;


import java.util.HashMap;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import net.sf.json.JSONObject;

/**
 * @author chenxl add by 2017-6-8 18:02:52
 * 
 *         使用权限校验
 *
 */

@Controller
@RequestMapping("/authorController")
public class AuthorController extends BaseController {

	private final Log log = LogFactory.getLog(AuthorController.class);

	@Autowired
	private AuthorService authorService;

	/**
	 * 系统使用权限校验 每月10号前，电子公函需完成【电子公函备案终审】，否则平台将停止为该GA下所有用户提供数据服务
	 * 
	 */
	@RequestMapping("/canUseSysCheck")
	@ResponseBody
	public JSONObject canUseSysCheck() {
		log.debug("canUseSysCheck begin .....");
		JSONObject obj = authorService.canUseSysCheck();
		System.out.println("print task = " + obj);
		return obj;
	}

	/**
	 * 办案人员查询权限校验
	 * 
	 */
	@RequestMapping(value = "/canSelectCheck")
	@ResponseBody
	public JSONObject canSelectCheck(@RequestBody HashMap<String, Object> map) {
		String elecId =(String)map.get("elecId");//公函编号
		String selectType =(String)map.get("selectType");//查询类型 1：按身份证 0： 号码
		List numInfo =(List)map.get("numInfo");//查询清单
		
		log.debug("canSelectCheck begin .....elecId = " + elecId+"== numInfo  = "+numInfo);		
		JSONObject obj = authorService.canSelectCheck(elecId,numInfo);
		log.debug("print result = " + obj);
		return obj;
	}

	
	/**
	 * 跳转至测试页面
	 * 
	 * @return 跳转路径
	 */
	@RequestMapping("/toTest")
	public ModelAndView toTest() {
		ModelAndView mv = new ModelAndView();
		mv.setViewName("test");
		return mv;
	}

}